var util = require('../../../utils/util')
Page({
  data: {
    itemArr: [],
    isLoading: false,
    page: 1,
  },

  getList() {
    this.setData({
      isLoading: true
    })
    let coordinate = wx.getStorageSync('coordinate')
    var data = {
      page: this.data.page,
      limit: 10,
      latitude: coordinate.latitude,
      altitude: coordinate.altitude
    }
    util.sendRequest('collect/shop', 'GET', data).then(res => {
      console.log(res)
      if (res.data.code === 0) {
        let result = res.data.result
        var itemArr = []
        for (let i in result.data) {
          itemArr[i] = result.data[i].shop
        }
        this.setData({
          itemArr,
          requestInfo: result,
          isLoading: false,
        })
      }
    })
  },

  onLoad: function (options) {
    wx.getSystemInfo({
      success: (res) => {
        getApp().globalData.windowHeightNotab = res.windowHeight;
        this.setData({
          hoverHeight: getApp().globalData.windowHeightNotab - getApp().globalData.navHeight,
        })
      },
    })
    this.getList()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})